{% extends "base.html" %}

{% block content %}
<div class="admin-dashboard container">
    <div class="admin-header">
        <h1>数据管理</h1>
        <a href="{{ url_for('admin.index') }}" class="btn">返回首页</a>
    </div>

    <div class="table-container card">
        <h2>夫妻数据管理</h2>
        <table class="admin-table">
            <thead>
                <tr>
                    <th>季数</th>
                    <th>夫妻</th>
                    <th>点赞数</th>
                    <th>投票数据</th>
                </tr>
            </thead>
            <tbody>
                {% for couple in couples %}
                <tr>
                    <td>第{{ couple.season }}季</td>
                    <td onclick="window.location.href='{{ url_for('main.couple_detail', id=couple.id) }}'">{{ couple.husband_name }} & {{ couple.wife_name }}</td>
                    <td>
                        <div class="stats-control">
                            <input type="number" class="form-control likes-input" value="{{ couple.likes_count }}" min="0"
                                   data-id="{{ couple.id }}">
                            <button class="btn btn-sm save-likes" data-id="{{ couple.id }}">
                                <i class="fas fa-save"></i>
                            </button>
                        </div>
                    </td>
                    <td>
                        <div class="stats-control">
                            <div class="vote-input-group">
                                <label>继续:</label>
                                <input type="number" class="form-control vote-input stay" 
                                       value="{{ couple.votes.filter_by(vote_type='stay_together').count() }}" min="0"
                                       data-id="{{ couple.id }}" data-type="stay_together">
                            </div>
                            <div class="vote-input-group">
                                <label>分手:</label>
                                <input type="number" class="form-control vote-input divorce" 
                                       value="{{ couple.votes.filter_by(vote_type='divorce').count() }}" min="0"
                                       data-id="{{ couple.id }}" data-type="divorce">
                            </div>
                            <button class="btn btn-sm save-votes" data-id="{{ couple.id }}">
                                <i class="fas fa-save"></i>
                            </button>
                        </div>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}

{% block styles %}
<style>
.stats-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.vote-input-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.vote-input-group label {
    white-space: nowrap;
}

.form-control {
    width: 80px;
}

.btn-sm {
    padding: 4px 8px;
}
</style>
{% endblock %}

{% block scripts %}
<script src="{{ url_for('static', filename='js/admin.js') }}"></script>
{% endblock %} 